<?php
	require_once (dirname(__FILE__)."/../../config/Config.inc");
	require_once (dirname(__FILE__)."/../../config/api.inc");
	require_once ("load.php");
	
	$parm = requestArrayParm($_REQUEST);
	
	$result['status'] = '0';
	
	if($parm['m'] == 'info')
	{
		unset($wheres);
		$wheres['id'] = $userinfo['id'];
		$info = _SqlTool::getInfo('users', $wheres);
		
		$result['status'] = '1';
		
		$result['bank'] = json_decode($info['bank'],true);
		$result['alipay'] = json_decode($info['alipay'],true);
		
		unset($wheres);
	
		$wheres['userid'] = $userinfo['id'];
		
		$wheres['addtime'] =  array('<=',time());
		
		$result['yue'] = _SqlTool::getSum('jyinfo', $wheres, array(),'money');
		
		/*//查询用户的提现金额
		unset($wheres);
	
		$wheres['userid'] = $userinfo['id'];
		
		$wheres['status'] = '1';
		
		$txSum = _SqlTool::getSum('txinfo', $wheres, array(),'money');
		*/
		unset($wheres);
	
		$wheres['userid'] = $userinfo['id'];
		
		$between['start'] = strtotime(date('Y-m-d'));
		
		$between['end'] = strtotime(date('Y-m-d'))+86399;
		
		$wheres['money'] = array('>',0);
		
		$result['jrfl'] = _SqlTool::getSum('jyinfo', $wheres, $between,'money');
		
		unset($wheres);
	
		$wheres['userid'] = $userinfo['id'];
		
		$wheres['addtime'] =  array('<=',time());
		
		$wheres['money'] = array('>',0);
		
		$result['ljfl'] = _SqlTool::getSum('jyinfo', $wheres, array(),'money');
		
	}
	
	if($parm['m'] == 'bank')
	{
		unset($where,$data,$bank);
		
		if(!empty($parm['name']) && !empty($parm['idcard']))
		{
			$data['name'] = $parm['name'];
			$data['idcard'] = $parm['idcard'];
		}
		
		if(!empty($parm['bankId'])  && !empty($parm['bankName']) && !empty($parm['bankNum']) && !empty($parm['bankPhone']))
		{
			$where['id'] = $userinfo['id'];
			$bank['bankId'] = $parm['bankId'];
			$bank['bankName'] = $parm['bankName'];
			$bank['bankNum'] = $parm['bankNum'];
			$bank['bankPhone'] = $parm['bankPhone'];
			$data['bank'] = json_encode($bank);
			$resup = _SqlTool::setInfo('users', $where, $data);
			if($resup)
			{
				$result['status'] = '1';
				$result['msg'] = '绑定成功';
			}
			else
			{
				$result['msg'] = '绑定失败';
			}
		}
		else
		{
			$result['msg'] = '缺少参数';
		}
	}
	
	if($parm['m'] == 'alipay')
	{
		unset($where,$data,$alipay);
		
		if(!empty($parm['name']) && !empty($parm['idcard']))
		{
			$data['name'] = $parm['name'];
			$data['idcard'] = $parm['idcard'];
		}
		
		if(!empty($parm['alipayNum']))
		{
			$where['id'] = $userinfo['id'];
			$alipay['alipayNum'] = $parm['alipayNum'];
			$data['alipay'] = json_encode($alipay);
			$resup = _SqlTool::setInfo('users', $where, $data);
			if($resup)
			{
				$result['status'] = '1';
				$result['msg'] = '绑定成功';
			}
			else
			{
				$result['msg'] = '绑定失败';
			}
		}
		else
		{
			$result['msg'] = '缺少参数';
		}
	}
	
	echoJSON($result);
	
	